package com.itheima.demo04;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author Zhang_Han
 * @version 1.0
 * @date 2020/7/14 9:39
 */
public class Demo_002 {
    public static void main(String[] args) {
        ThreadPoolExecutor tpe = new ThreadPoolExecutor(
                2,
                3,
                10,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(3),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());

        for (int i = 0; i < 10; i++) {
            tpe.submit(() -> {
                System.out.println(Thread.currentThread().getName() + "..." );
            });
        }

        tpe.shutdown();

    }
}
